Telegram Group & Telegram Channel
📊 Своя метрика в Prometheus

Хотите отслеживать, сколько запросов прилетает в ваше приложение? Или сколько задач выполнилось? Делается это за 5 шагов — через кастомные метрики.

Попробуем реализовать пример: считаем количество HTTP-запросов в приложении на Go.

1. Подключаем библиотеку Prometheus:
go get github.com/prometheus/client_golang/prometheus


2. Создаём счётчик:
var requestCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "myapp_http_requests_total",
Help: "Total number of HTTP requests",
})


3. Регистрируем метрику:
func init() {
prometheus.MustRegister(requestCounter)
}


requestCounter будет инкрементироваться при запросе приложения.

4. Добавляем endpoint для Prometheus:
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))


5. Пишем конфиг на стороне Prometheus
scrape_configs:
- job_name: 'myapp'
metrics_path: /metrics
static_configs:
- targets: ['localhost:8080']


📍 Всё — теперь http://localhost:8080/metrics отдаёт данные, которые можно добавить в дашборд в Prometheus.

🐸Библиотека devops'a #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/devopsslib/3737
Create:
Last Update:

📊 Своя метрика в Prometheus

Хотите отслеживать, сколько запросов прилетает в ваше приложение? Или сколько задач выполнилось? Делается это за 5 шагов — через кастомные метрики.

Попробуем реализовать пример: считаем количество HTTP-запросов в приложении на Go.

1. Подключаем библиотеку Prometheus:

go get github.com/prometheus/client_golang/prometheus


2. Создаём счётчик:
var requestCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "myapp_http_requests_total",
Help: "Total number of HTTP requests",
})


3. Регистрируем метрику:
func init() {
prometheus.MustRegister(requestCounter)
}


requestCounter будет инкрементироваться при запросе приложения.

4. Добавляем endpoint для Prometheus:
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))


5. Пишем конфиг на стороне Prometheus
scrape_configs:
- job_name: 'myapp'
metrics_path: /metrics
static_configs:
- targets: ['localhost:8080']


📍 Всё — теперь http://localhost:8080/metrics отдаёт данные, которые можно добавить в дашборд в Prometheus.

🐸Библиотека devops'a #буст

BY Библиотека девопса | DevOps, SRE, Sysadmin




Share with your friend now:
tg-me.com/devopsslib/3737

View MORE
Open in Telegram


Библиотека девопса | DevOps SRE Sysadmin Telegram | DID YOU KNOW?

Date: |

What is Telegram?

Telegram’s stand out feature is its encryption scheme that keeps messages and media secure in transit. The scheme is known as MTProto and is based on 256-bit AES encryption, RSA encryption, and Diffie-Hellman key exchange. The result of this complicated and technical-sounding jargon? A messaging service that claims to keep your data safe.Why do we say claims? When dealing with security, you always want to leave room for scrutiny, and a few cryptography experts have criticized the system. Overall, any level of encryption is better than none, but a level of discretion should always be observed with any online connected system, even Telegram.

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

Библиотека девопса | DevOps SRE Sysadmin from hk


Telegram Библиотека девопса | DevOps, SRE, Sysadmin
FROM USA